﻿using System;
namespace Myconsole
{
    /// <summary>
    /// 输出四种小星星类型
    /// </summary>
    class Program
    {
        private const int LinesCount = 11;
        static void Main(string[] args)
        {
            Console.Clear();
            RightAngledTriangle();  //输出直角三角形
            IsocelesTriangle();   //输出等腰三角形
            HollowTriangle();  //输出空心等腰三角形
            HollowDiamond();  //输出空心菱形
            Console.ReadKey();
        }
        ///<summary>
        ///输出直角三角形
        ///</summary>
        static void RightAngledTriangle()
        {
            Console.WriteLine("输出行数为11的直角三角形");
            for (int i = 0; i <= LinesCount; i++)
            {
                var stars = new String('*', i);
                Console.WriteLine(stars);
            }
        }
        ///<summary>
        ///输出等腰三角形
        /// </summary>
        static void IsocelesTriangle()
        {
            Console.WriteLine("输出行数为11的等腰三角形");
            for (int j = 1; j <= LinesCount; j++)
            {
                var blank = new String(' ', LinesCount - j); //控制空格的输出
                var stars = new String('*', j * 2 - 1);  //控制星星的输出
                Console.WriteLine(blank + stars);
            }
        }
        ///<summary>
        ///输出空心等腰三角形
        /// </summary>
        static void HollowTriangle()
        {
            Console.WriteLine("输出行数为11的空心等腰三角形");
            for (int i = 1; i <= LinesCount; i++)
            {
                var blank = new String(' ', LinesCount - i);
                if (i == 1 || i == LinesCount)
                {
                    var stars = new String('*', 2 * i - 1);
                    Console.WriteLine(blank + stars);
                }
                else
                {
                    var blankMiddle = new String(' ', 2 * i - 3);
                    Console.WriteLine(blank + "*" + blankMiddle + "*");
                }
            }
        }

        ///<summary>
        ///输出行数为11的空心菱形
        /// </summary>
        static void HollowDiamond()
        {
            Console.WriteLine("输入行数为11的空心菱形");
            for (int i = 1; i <= LinesCount; i++)//空心菱形上半部分
            {
                var blank = new String(' ', LinesCount - i);
                if (i == 1)
                {
                    Console.WriteLine(blank + "*");
                }
                else
                {
                    var blankMiddle = new String(' ', 2 * i - 3);
                    Console.WriteLine(blank + "*" + blankMiddle + "*");
                }
            }
            for (int i = LinesCount - 1; i > 0; i--)//空心菱形下半部分
            {
                var blank = new String(' ', LinesCount - i);
                if (i == 1)
                {
                    Console.WriteLine(blank + "*");
                }
                else
                {
                    var blankMiddle = new String(' ', 2 * i - 3);
                    Console.WriteLine(blank + "*" + blankMiddle + "*");
                }
            }
        }
    }
}